package com.yupi.springbootinit.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.exception.BusinessException;
import com.yupi.springbootinit.mapper.InterfaceInfoMapper;
import model.entity.InterfaceInfo;
import org.apache.commons.lang3.StringUtils;
import service.InnerInterfaceInfoService;

import javax.annotation.Resource;

/**
 * @author 25169
 */
@Service(version = "${dubbo.service.version}")
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;


    @Override
    public InterfaceInfo getInterfaceInfo(String url, String method) {
        if(StringUtils.isAnyBlank(url,method)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        LambdaQueryWrapper<InterfaceInfo> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(InterfaceInfo::getUrl,url);
        queryWrapper.eq(InterfaceInfo::getMethod,method);
        InterfaceInfo interfaceInfo = interfaceInfoMapper.selectOne(queryWrapper);
        return interfaceInfo;
    }
}
